package com.schematic.flixel.donquicoco
{
	import flashx.textLayout.formats.FormatValue;
	
	import org.flixel.FlxG;
	import org.flixel.FlxObject;
	import org.flixel.FlxSound;
	


public class Mario extends BaseSprite	
	
{
	//----------------------------------
	//  SoundLoop
	//----------------------------------
	/**
	 *  @private
	 */
	public var sound:FlxSound;		
    //--------------------------------------------------------------------------
    //
    // Constructor
    //
    //--------------------------------------------------------------------------

    /**
     * Creates a new instance of this class.
     */
    public function Mario(x:Number = 0, y:Number = 0)
    {
        super(x, y);
		
		sound = FlxG.play(Sounds.SOUND_LOOP, 0.1, true)
		sound.fadeIn(3);
		
        loadGraphic(Skins.MARIO, true, false, 16, 30, true);
        horizontalSpeed = 90;
        verticalSpeed = 55;
		
        addAnimation(
            BaseSprite.MOVE_RIGHT,
            [1, 2, 3],
            frameRate,
            true
        );
        addAnimation(
            BaseSprite.MOVE_LEFT,
            [4, 5, 6],
            frameRate,
            true
        );
        addAnimation(
            BaseSprite.STOP_MOVING,
            [0, 0, 0, 0, 0, 7, 7, 7, 7, 0],
            frameRate,
            true
        );

		addAnimation(
			BaseSprite.MOVE_UP,
			[18,19,20,21],
			frameRate,
			true
		);	
		addAnimation(
			BaseSprite.MOVE_DOWN,
			[21,20,19,18],
			frameRate,
			true
		);
		
		addAnimation(
			BaseSprite.FALL,
			[16,17],
			frameRate,
			true
		);	
        
        addAnimation(
            BaseSprite.PAUSE_ON_LADDER,
            [21],
            frameRate,
            false
        );
        
		addAnimation(
			"weaponWalkLeft",
			[16, 17, 18],
			frameRate,
			true
		);	
		addAnimation(
			"weaponWalkRight",
			[19, 20, 21],
			frameRate,
			true
		);	
    }
	
    //--------------------------------------------------------------------------
    //
    //  Overridden Methods - FlxSprite
    //
    //--------------------------------------------------------------------------	
	
    override public function kill():void
	{
		super.kill();
		sound.fadeOut(2);
		FlxG.play(Sounds.MARIO_DIES,0.2);
		FlxG.quake.start(0.01,0.5)
		
	}
    
    override public function hitBottom(Contact:FlxObject, Velocity:Number):void
    {
        trace ("hit botton");
    }
	
}

}